#pragma once
#include "Model.h"
#include "StarlabPlugin.h"
#include "RichParameterSet.h"

/// Overload this directly when you need document access (i.e. adding a new model)
class FilterPlugin : public StarlabPlugin{
public:
    /// The core function of a filter, run your algorithm in here
    virtual void applyFilter(Document* document, RichParameterSet* parameters, StarlabDrawArea* drawArea) = 0;
    /// Provides parameters to the filter (optional)
    virtual void initParameters(Document* /*document*/, RichParameterSet* /*parameters*/, StarlabDrawArea* /*drawArea*/){}
};

/**
 * @brief The interface of a plugin which acts as a function call on the selected model.
 * @ingroup StarlabPluginInterfaces 
 *
 * When invoked, the plugin will pop up a parameter window (if parameters exist) 
 * which the user will be able to tune before execution. 
 * 
 * Filter plugins can be found under the "filter" menu.
 * Some filter plugins might also have an associated button in the toolbar.
 */
class SelectionFilterPlugin : public FilterPlugin{
public:
    virtual void applyFilter(Model* model, RichParameterSet* parameters, StarlabDrawArea* drawArea) = 0;
    virtual void initParameters(Model* /*model*/, RichParameterSet* /*parameters*/, StarlabDrawArea* /*drawArea*/){}
    
    /// @{ overloads for DocumentFilterPlugin
    private: 
        void applyFilter(Document* document, RichParameterSet* parameters, StarlabDrawArea* drawArea){
            applyFilter(document->selectedModel(), parameters, drawArea);            
        }
        void initParameters(Document* document, RichParameterSet* parameters, StarlabDrawArea* drawArea){
            initParameters(document->selectedModel(), parameters, drawArea);
        }
    /// @}
};

Q_DECLARE_INTERFACE(FilterPlugin, "starlab.FilterPlugin/1.1")
